//
//  LSBusinessTripApplyLocationTableViewCell.m
//  LaSaCivilAffairsDepartment
//
//  Created by 聂志康 on 2019/1/22.
//  Copyright © 2019 wpkj. All rights reserved.
//

#import "LSBusinessTripApplyLocationTableViewCell.h"

@interface LSBusinessTripApplyLocationTableViewCell () <UITextFieldDelegate>

@end

@implementation LSBusinessTripApplyLocationTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        self.separatorInset = UIEdgeInsetsMake(0, ScreenWidth, 0, 0);
        [self.contentView addSubview:[[UILabel alloc] initWithFrame:CGRectMake(15+(ScreenWidth-30-50-30-10)/2, 0, 30, 38) andText:@"至" andTextColor:hexColor(333333) andFont:[UIFont fontWithName:@"SourceHanSansCN-Regular" size:14] andTextAlignment:NSTextAlignmentCenter]];
        [self.contentView addSubview:self.fromTF];
        [self.contentView addSubview:self.toTF];
        [self.contentView addSubview:self.editButton];
    }
    return self;
}

- (void)layoutSubviews {
    [super layoutSubviews];
    WS
    [self.fromTF mas_remakeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(weakSelf.contentView.mas_left).with.offset(15);
        make.top.equalTo(weakSelf.contentView.mas_top);
        make.width.mas_equalTo((ScreenWidth-30-50-30-10)/2);
        make.height.mas_equalTo(36);
    }];
    [self.toTF mas_remakeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(weakSelf.fromTF.mas_right).with.offset(30);
        make.top.equalTo(weakSelf.contentView.mas_top);
        make.width.mas_equalTo((ScreenWidth-30-50-30-10)/2);
        make.height.mas_equalTo(36);
    }];
}

- (UITextField *)fromTF {
    if (!_fromTF) {
        _fromTF = [[UITextField alloc] init];
        _fromTF.layer.cornerRadius = 4;
        _fromTF.layer.masksToBounds = true;
        _fromTF.layer.borderWidth = 1;
        _fromTF.layer.borderColor = UIColor.grayColor.CGColor;
        _fromTF.delegate = self;
    }
    return _fromTF;
}

- (UITextField *)toTF {
    if (!_toTF) {
        _toTF = [[UITextField alloc] init];
        _toTF.layer.cornerRadius = 4;
        _toTF.layer.masksToBounds = true;
        _toTF.layer.borderWidth = 1;
        _toTF.layer.borderColor = UIColor.grayColor.CGColor;
    }
    return _toTF;
}

- (UIButton *)editButton {
    if (!_editButton) {
        _editButton = [[UIButton alloc] initWithFrame:CGRectMake(ScreenWidth-15-50, 0, 50, 36)];
        [_editButton setTitleColor:UIColor.whiteColor forState:UIControlStateNormal];
        [_editButton setTitle:@"+添加" forState:UIControlStateNormal];
        _editButton.layer.cornerRadius = 4;
        _editButton.layer.masksToBounds = true;
        _editButton.backgroundColor = NAV_COLOR;
        _editButton.titleLabel.font = [UIFont fontWithName:@"SourceHanSansCN-Regular" size:14];
    }
    return _editButton;
}

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
